:root {
    --color-1: #FF9999;
    --color-2: #99FF99;
    --color-3: #9999FF;
    --color-4: #FFFF99;
}

#game {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    font-family: 'Arial', sans-serif;
    overflow: hidden;
    position: relative;
}

#start-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: relative;
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

.start-content {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px 60px;
    border-radius: 30px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    animation: fadeIn 1s ease-out;
    max-width: 600px;
    width: 90%;
}

.game-title {
    font-size: 56px;
    color: #2c3e50;
    margin-bottom: 30px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.1);
    animation: titleFloat 3s ease-in-out infinite;
    background: linear-gradient(45deg, #2c3e50, #3498db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-description {
    margin: 30px 0;
    color: #34495e;
    font-size: 20px;
    line-height: 1.8;
    text-align: center;
}

.game-description p {
    margin: 15px 0;
    opacity: 0;
    animation: slideUp 0.5s ease forwards;
}

.game-description p:nth-child(1) { animation-delay: 0.3s; }
.game-description p:nth-child(2) { animation-delay: 0.6s; }

.start-button {
    font-size: 26px;
    padding: 18px 50px;
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    margin-top: 30px;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0;
    animation: fadeIn 0.5s ease 0.9s forwards;
}

.start-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 25px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, #2980b9, #3498db);
}

.floating-blocks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.float-block {
    position: absolute;
    width: 60px;
    height: 60px;
    background: var(--color);
    border-radius: 12px;
    animation: float 6s ease-in-out infinite;
    animation-delay: var(--delay);
    opacity: 0.8;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.float-block:nth-child(1) { top: 20%; left: 20%; }
.float-block:nth-child(2) { top: 60%; left: 80%; }
.float-block:nth-child(3) { top: 80%; left: 30%; }
.float-block:nth-child(4) { top: 30%; left: 70%; }

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-100px) rotate(180deg);
    }
}

@keyframes titleFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* 对战模式样式 */
#battle-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f);
}

#battle-screen h1 {
    color: white;
    font-size: 42px;
    margin-bottom: 40px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.battle-menu {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 30px;
}

.battle-button {
    padding: 15px 40px;
    font-size: 20px;
    background: linear-gradient(45deg, #2193b0, #6dd5ed);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.battle-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.join-room-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

#room-number-input {
    padding: 15px;
    font-size: 18px;
    border: none;
    border-radius: 8px;
    width: 200px;
    text-align: center;
    letter-spacing: 2px;
    background: rgba(255, 255, 255, 0.9);
}

#room-number-input::placeholder {
    color: #999;
}

#waiting-screen {
    text-align: center;
    color: white;
    margin-top: 40px;
}

#waiting-screen h2 {
    font-size: 32px;
    margin-bottom: 20px;
}

.room-number {
    font-size: 24px;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 30px;
    border-radius: 10px;
    display: inline-block;
    margin: 20px 0;
}

.loading-animation {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
}

.loading-dot {
    width: 15px;
    height: 15px;
    background: white;
    border-radius: 50%;
    animation: loadingDot 1.5s infinite ease-in-out;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loadingDot {
    0%, 100% {
        transform: scale(1);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.5);
        opacity: 1;
    }
}

/* 对战游戏界面样式 */
#battle-game-screen {
    padding: 20px;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f);
}

.battle-container {
    display: flex;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: 20px;
}

.player-board, .opponent-board {
    flex: 1;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.player-info {
    margin-bottom: 20px;
    text-align: center;
}

.player-name, .opponent-name {
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
}

.player-score, .time-left, .opponent-score {
    font-size: 18px;
    color: #34495e;
}

#player-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.opponent-status {
    text-align: center;
    font-size: 18px;
    color: #666;
    margin-top: 20px;
}

.battle-controls {
    text-align: center;
    margin-top: 20px;
}

#battle-quit-btn {
    padding: 10px 30px;
    font-size: 18px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

#battle-quit-btn:hover {
    background: #c0392b;
}

/* 方块样式 */
.cell {
    width: var(--block-size, 60px);
    height: var(--block-size, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--block-size, 60px) * 0.4);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
    color: transparent;
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
    margin: 0;
    padding: 0;
}

.cell:hover {
    transform: scale(1.05);
}

.cell.selected {
    transform: scale(0.95);
    box-shadow: 0 0 12px rgba(0,0,0,0.2);
    animation: pulse 1s infinite;
}

/* 方块颜色样式 */
.cell[data-value="1"] { 
    background: linear-gradient(135deg, #FF9999, #FF5555); 
}
.cell[data-value="2"] { 
    background: linear-gradient(135deg, #99FF99, #55FF55); 
}
.cell[data-value="3"] { 
    background: linear-gradient(135deg, #9999FF, #5555FF); 
}
.cell[data-value="4"] { 
    background: linear-gradient(135deg, #FFFF99, #FFFF55); 
}

/* 特殊方块样式 */
.special-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    z-index: 2;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    animation: specialPulse 1.5s infinite ease-in-out;
}

.cell[data-special="bomb"] {
    background: linear-gradient(135deg, #ff4d4d, #ff1a1a);
    box-shadow: 0 0 10px rgba(255, 77, 77, 0.5);
}

.cell[data-special="lightning"] {
    background: linear-gradient(135deg, #ffeb3b, #ffc107);
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
}

.cell[data-special="rainbow"] {
    background: linear-gradient(135deg, 
        #ff0000, #ff7f00, #ffff00, #00ff00, 
        #0000ff, #4b0082, #8f00ff
    );
    animation: rainbowShift 3s linear infinite;
}

.cell[data-special="star"] {
    background: linear-gradient(135deg, #e91e63, #9c27b0);
    box-shadow: 0 0 15px rgba(233, 30, 99, 0.6);
    animation: magicGlow 2s infinite alternate;
}

@keyframes specialPulse {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes rainbowShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes magicGlow {
    from { box-shadow: 0 0 15px rgba(233, 30, 99, 0.6); }
    to { box-shadow: 0 0 25px rgba(156, 39, 176, 0.8); }
}

/* 道具栏样式 */
.items-bar-container {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 15px;
    margin: 20px auto;
    max-width: 600px;
}

.items-title {
    writing-mode: vertical-lr;
    text-orientation: upright;
    font-size: 20px;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    background: linear-gradient(45deg, #f1c40f, #f39c12);
    padding: 15px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 2px;
}

.items-bar {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    flex: 1;
}

.item-button {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.item-button:hover:not(.disabled) {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.item-button.disabled {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.item-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-button.disabled .item-count {
    background: #95a5a6;
}

.item-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    margin-bottom: 8px;
    z-index: 100;
}

.item-button:hover .item-tooltip {
    opacity: 1;
    visibility: visible;
}

/* 连击效果样式 */
.combo-popup {
    position: fixed;
    transform: translateY(0);
    opacity: 1;
    pointer-events: none;
    z-index: 1000;
    transition: all 1s ease-out;
    text-align: center;
    margin-left: -40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.combo-count {
    font-size: 32px;
    font-weight: bold;
    color: #ff4081;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: pulseCombo 0.5s ease-in-out infinite;
}

.combo-text {
    font-size: 24px;
    color: #f50057;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

@keyframes pulseCombo {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* 动画效果 */
@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% { transform: scale(0.95); }
    50% { transform: scale(1); }
    100% { transform: scale(0.95); }
}

/* 成就按钮样式 */
.achievements-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 10;
}

.achievements-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* 成就面板样式 */
.achievements-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.achievements-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(0,0,0,0.1);
}

.achievements-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 24px;
}

.close-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    line-height: 1;
}

.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-radius: 12px;
    background: #f8f9fa;
    transition: all 0.3s ease;
}

.achievement-item.unlocked {
    background: linear-gradient(45deg, #E3F2FD, #BBDEFB);
}

.achievement-item.locked {
    opacity: 0.7;
    filter: grayscale(1);
}

.achievement-icon {
    font-size: 30px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.achievement-desc {
    color: #666;
    font-size: 0.9em;
}

.achievement-unlocked {
    color: #4CAF50;
    font-size: 24px;
}

/* 成就通知样式 */
.achievement-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    animation: slideInRight 0.5s ease;
    z-index: 1000;
}

.achievement-notification.fade-out {
    animation: slideOutRight 0.5s ease forwards;
}

.achievement-notification .achievement-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
}

.achievement-notification .achievement-content {
    flex: 1;
}

.achievement-notification .achievement-title {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 3px;
}

.achievement-notification .achievement-description {
    color: #666;
    font-size: 0.9em;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
}

.sub-buttons {
    display: flex;
    gap: 20px;
}

.menu-button {
    font-size: 24px;
    padding: 15px 40px;
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.menu-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, #2980b9, #3498db);
}

#battle-btn {
    font-size: 28px;
    padding: 18px 50px;
}

/* 移除旧的按钮样式 */
.start-button, .achievements-btn {
    position: static;
    z-index: auto;
}

/* 方块动画速度优化 */
.cell.falling {
    transition: transform 0.02s ease-in-out;
}

.cell.matched {
    animation: eliminate 0.1s ease-out;
}

@keyframes eliminate {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3) rotate(15deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
}

@keyframes cellAppear {
    from {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.cell.new-block {
    animation: cellAppear 0.02s ease-out;
}

.cell.swapping {
    transition: transform 0.05s ease-in-out;
    z-index: 2;
}

/* 游戏规则面板样式 */
.rules-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(0,0,0,0.1);
}

.rules-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 24px;
}

.rules-content {
    color: #2c3e50;
}

.rules-content h3 {
    margin: 20px 0 10px;
    color: #2980b9;
}

.rules-content ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.rules-content li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.rules-content li:last-child {
    border-bottom: none;
}